package xworker.javafxexamples;

import javafx.scene.Node;
import javafx.scene.control.TextArea;
import javafx.scene.layout.VBox;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;

//对应模型xworker.javafx.examples.JavaFXMobileExamples
//根节点模型：xworker.javafxexamples.JavaFXMobileExamples/@Nodes/@rootVBox
public class JavaFXMobileExamples {
    public static void menuDoAction(ActionContext actionContext){
        World world = World.getInstance();
        Thing thing = actionContext.getObject("thing");
        Thing ext = world.getThing(thing.getString("extends"));
        if(ext != null){
            ActionContext ac = new ActionContext();
            Thing nodes = ext.getThing("Nodes@0");
            if(nodes != null){
                VBox exampleBox = actionContext.getObject("exampleBox");
                exampleBox.getChildren().clear();
                nodes.doAction("create", ac);

                exampleBox.getChildren().add((Node) ac.getObject("rootNode"));

                //xml代码
                TextArea codeText = actionContext.getObject("codeText");
                codeText.setText(nodes.toXML());
            }
        }
    }
}
